﻿using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace teavch.Util.SitemapWriter
{

	public class SitemapUrl
	{

		public Location Location { get; set; }
		public LastModified LastModified { get; set; }
		public ChangeFrequency ChangeFrequency { get; set; }
		public Priority Priority { get; set; }

		public ImageImage ImageImage { get; set; }
		public VideoVideo VideoVideo { get; set; }
		public Title Title { get; set; }
		public Description Description { get; set; }

	}

	public class SitemapUrls<T> : List<T> where T: SitemapUrl
	{

	}

	public abstract class SitemapUrlAttribute
	{
		public string XmlTagPrefix { get; set; }
		public string XmlTag { get; set; }
		public string Xml { get { return "<" + this.XmlTag + ">" + this.Value + "</" + this.XmlTag + ">"; } }
		public string Value { get; set; }
	}

	public class Location : SitemapUrlAttribute
	{
		public Location()
		{
			this.XmlTag = "loc";
		}

		public Location( string value )
			: this()
		{
			this.Value = value;
		}

		public Location( string value, string xmlTag, string xmlTagPrefix )
			: this( value )
		{
			this.XmlTagPrefix = xmlTagPrefix;
			this.XmlTag = xmlTag;
		}
	}

	public class LastModified : SitemapUrlAttribute
	{
		public LastModified()
		{
			this.XmlTag = "lastmod";
		}

		public LastModified( string value )
			: this()
		{
			this.Value = value;
		}
	}

	public class ChangeFrequency : SitemapUrlAttribute
	{
		public ChangeFrequency()
		{
			this.XmlTag = "changefreq";
		}

		public ChangeFrequency( string value )
			: this()
		{
			this.Value = value;
		}
	}

	public class Priority : SitemapUrlAttribute
	{
		public Priority()
		{
			this.XmlTag = "priority";
		}

		public Priority( string value )
			: this()
		{
			this.Value = value;
		}
	}

	public class ImageImage : SitemapUrlAttribute
	{
		public ImageImage()
		{
			this.XmlTagPrefix = "image";
			this.XmlTag = "image";
			this.Location = new List<Location>();
		}

		public ImageImage( string value )
			: this()
		{
			this.Value = value;
		}

		public List<Location> Location { get; set; }
	}

	public class VideoVideo : SitemapUrlAttribute
	{
		public VideoVideo()
		{
			this.XmlTagPrefix = "video";
			this.XmlTag = "video";
			this.ContentLocation = new Location( "", "content_loc", "video" );
			this.PlayerLocation = new Location( "", "player_loc", "video" );
			this.ThumbnailLocation = new Location( "", "thumbnail_loc", "video" );
		}

		public VideoVideo( string value )
		{
			this.Value = value;
		}

		public Location ContentLocation { get; set; }
		public Location PlayerLocation { get; set; }
		public Location ThumbnailLocation { get; set; }
		public Title Title { get; set; }
		public Description Description { get; set; }
	}

	public class Title : SitemapUrlAttribute
	{
		public Title()
		{
			this.XmlTag = "title";
		}

		public Title( string value )
			: this()
		{
			this.Value = value;
		}

		public Title( string value, string xmlTag, string xmlTagPrefix )
			: this( value )
		{
			this.XmlTagPrefix = xmlTagPrefix;
			this.XmlTag = xmlTag;
		}
	}

	public class Description : SitemapUrlAttribute
	{
		public Description()
		{
			this.XmlTag = "description";
		}

		public Description( string value )
			: this()
		{
			this.Value = value;
		}

		public Description( string value, string xmlTag, string xmlTagPrefix )
			: this( value )
		{
			this.XmlTagPrefix = xmlTagPrefix;
			this.XmlTag = xmlTag;
		}
	}

}